using System;
using System.Drawing;

namespace OpenComposite.Base.Designer
{
	public class NoClipTextBox : OpenComposite.Base.Designer.TextBox
	{
		public NoClipTextBox()
		{
			this.ReadOnly = true;
			this.AutoSize = false;
		}
		public override bool NoClip
		{
			get { return true; }
		}
		public override bool CanResize
		{
			get { return true; }
		}
		public override bool CanSelect
		{
			get { return true; }
		}

		public bool IsResizedByUser
		{
			get { return _isResizedByUser; }
		}
		public override ResizeSides ResizableSides
		{
			get { return ResizeSides.All; }
		}

		protected override void OnSizeChanged(EventArgs e)
		{
			if ( Parent != null ) {
				this.Location = new Point(-( this.Width / 2 ) + ( Parent.Width / 2 ), Parent.Height);
			}
			base.OnSizeChanged(e);
		}

		//protected override void OnTextChanged(EventArgs e)
		//{
		//    this.BeginUpdate();
		//    if ( this.AutoSize && this.DesignerViewControl != null ) {
		//        Rectangle rparent = Rectangle.Empty;
		//        if ( this.Parent != null )
		//            rparent = this.Parent.ClientRectangle;
		//        using ( Graphics g = this.DesignerViewControl.CreateGraphics() ) {
		//            SizeF s = g.MeasureString(this.Text, this.Font);
		//            this.Width = (int)Math.Ceiling(s.Width);
		//            this.Height = (int)Math.Ceiling(s.Height);
		//        }
		//    }
		//    this.EndUpdate();
		//}

		private bool _isResizedByUser = false;
	}
}
